<?php

namespace App\Jobs;

use App\Good;
use App\OrderGoods;
use App\OrderPay;
use App\Repositories\OrderRespository;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class CloseOrder implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    protected $order;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(OrderPay $orderPay,$delay)
    {
        $this->order=$orderPay;
        $this->delay(Carbon::now()->addMinutes($delay));
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
           $order= new OrderRespository();
           return  $order->cancelOrder($this->order);
    }
}
